﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="evk_kapital", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(EvkKapital))]
    public class EvkKapitalSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IEvkKapital clazz;
        
        public EvkKapitalSerializer(IEvkKapital clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("kapitali_suurus");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "float");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdFloat(((float)(clazz.KapitaliSuurus))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("kapitali_valuuta_tahis");
            if (clazz.KapitaliValuutaTahis!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KapitaliValuutaTahis))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KapitaliValuutaTahis");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="kapitali_suurus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>evk_kapital>kapitali_suurus");
                }
                clazz.KapitaliSuurus = new global::Xtee.Core.Schema.XsdFloat(Reader.ReadElementString("kapitali_suurus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>evk_kapital>kapitali_suurus", Reader.LocalName);
            }
            if (Reader.LocalName=="kapitali_valuuta_tahis") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>evk_kapital>kapitali_valuuta_tahis");
                }
                clazz.KapitaliValuutaTahis = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kapitali_valuuta_tahis")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>evk_kapital>kapitali_valuuta_tahis", Reader.LocalName);
            }
        }
    }
}
